/**
 */
package org.aphelie.chronicle.impl;

import java.util.Collection;
import org.aphelie.chronicle.ArcScore;
import org.aphelie.chronicle.ArcTuple;
import org.aphelie.chronicle.ChroniclePackage;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Arc Tuple</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.aphelie.chronicle.impl.ArcTupleImpl#getScores <em>Scores</em>}</li>
 *   <li>{@link org.aphelie.chronicle.impl.ArcTupleImpl#getOverall <em>Overall</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ArcTupleImpl extends ArcCategoryImpl implements ArcTuple {
	/**
	 * The cached value of the '{@link #getScores() <em>Scores</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getScores()
	 * @generated
	 * @ordered
	 */
	protected EList<ArcScore> scores;

	/**
	 * The default value of the '{@link #getOverall() <em>Overall</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getOverall()
	 * @generated
	 * @ordered
	 */
	protected static final int OVERALL_EDEFAULT = 0;
	/**
	 * The cached value of the '{@link #getOverall() <em>Overall</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getOverall()
	 * @generated
	 * @ordered
	 */
	protected int overall = OVERALL_EDEFAULT;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ArcTupleImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return ChroniclePackage.Literals.ARC_TUPLE;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<ArcScore> getScores() {
		if (scores == null) {
			scores = new EObjectContainmentEList<ArcScore>(ArcScore.class, this, ChroniclePackage.ARC_TUPLE__SCORES);
		}
		return scores;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public int getOverall() {
		return overall;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setOverall(int newOverall) {
		int oldOverall = overall;
		overall = newOverall;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ChroniclePackage.ARC_TUPLE__OVERALL, oldOverall, overall));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case ChroniclePackage.ARC_TUPLE__SCORES:
				return ((InternalEList<?>)getScores()).basicRemove(otherEnd, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case ChroniclePackage.ARC_TUPLE__SCORES:
				return getScores();
			case ChroniclePackage.ARC_TUPLE__OVERALL:
				return getOverall();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case ChroniclePackage.ARC_TUPLE__SCORES:
				getScores().clear();
				getScores().addAll((Collection<? extends ArcScore>)newValue);
				return;
			case ChroniclePackage.ARC_TUPLE__OVERALL:
				setOverall((Integer)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case ChroniclePackage.ARC_TUPLE__SCORES:
				getScores().clear();
				return;
			case ChroniclePackage.ARC_TUPLE__OVERALL:
				setOverall(OVERALL_EDEFAULT);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case ChroniclePackage.ARC_TUPLE__SCORES:
				return scores != null && !scores.isEmpty();
			case ChroniclePackage.ARC_TUPLE__OVERALL:
				return overall != OVERALL_EDEFAULT;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (overall: ");
		result.append(overall);
		result.append(')');
		return result.toString();
	}

} //ArcTupleImpl
